//
//  ExamineTableViewCell.m
//  OAProject
//
//  Created by yhj on 2017/2/22.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "ExamineTableViewCell.h"

@interface ExamineTableViewCell ()

// 名字
@property(nonatomic,strong)UILabel *nameLabel;

// 合同状态
@property(nonatomic,strong)UILabel *stateLabel;

// 箭头
@property(nonatomic,strong)UIImageView *arrowIcon;

@end

@implementation ExamineTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.arrowIcon.hidden=NO;

        _arrowIcon.image=[UIImage imageNamed:@"arrow"];

        self.nameLabel.font=Font_Number(16);

        self.stateLabel.font=Font_Number(14);

        self.backgroundColor=WhiteColor;

        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapEvent)];
        [self addGestureRecognizer:tap];

    }
    return self;
}

-(void)tapEvent
{
    if (_delegate&&[_delegate respondsToSelector:@selector(tapEvent)])
    {
        [_delegate tapEvent];
    }
}

// nameLabel
- (UILabel *)nameLabel
{

    if (!_nameLabel) {
        _nameLabel=[self getLabelWithText:@"深圳亿佳技术" font:Font_Number(16) textColor:[UIColor blackColor] textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.centerY.mas_equalTo(self);
        }];
    }
    return _nameLabel;
}

// stateLabel
- (UILabel *)stateLabel
{
    if (!_stateLabel) {
        _stateLabel=[self getLabelWithText:@"变更" font:Font_Number(14) textColor:Color999999 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_stateLabel];
        [_stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self);
            make.right.mas_equalTo(self.arrowIcon.mas_left).offset(-kmargin);
        }];
        
    }
    return _stateLabel;
}

// arrowIcon
-(UIImageView *)arrowIcon
{
    if (!_arrowIcon) {
        _arrowIcon=[UIImageView new];
        [self.contentView addSubview:_arrowIcon];

        [_arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin);
            make.centerY.mas_equalTo(self);
            make.size.mas_equalTo(CGSizeMake(kmargin,kmargin));
        }];
    }
    return _arrowIcon;
}

@end
